package com.sgolub.commanndsonline.dao.entity;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.sgolub.commanndsonline.domain.entity.AdvertisingRegistry;
import com.sgolub.commanndsonline.domain.entity.UserBasket;
import com.sgolub.commanndsonline.domain.entity.UserOrder;
import com.sgolub.commanndsonline.domain.entity.UserOrderDetail;
import com.sgolub.commanndsonline.domain.sec.SecUser;

/**
 * @author sgolub
 *
 */
@Repository
public class UserOrderDetailDAOImpl implements UserOrderDetailDAO {

    @Autowired
    private SessionFactory sessionFactory;
    
	public UserOrderDetail get(Integer id) {
		UserOrderDetail list = (UserOrderDetail)sessionFactory.
								getCurrentSession().get(UserOrderDetail.class, id);
		return list;
	}

	
	public void add(UserOrderDetail item) {
		sessionFactory.getCurrentSession().save(item);

	}

	public void update(UserOrderDetail item) {
		// TODO Auto-generated method stub

	} 

	public void remove(Integer id) {
		// TODO Auto-generated method stub
	}
	
	@SuppressWarnings("unchecked")
    public List<UserOrderDetail> listDetailByOrderId(Integer orderId){
		
		String sql = "from UserOrderDetail where fk_order_id = " + orderId;
		Query queryH = sessionFactory.getCurrentSession().createQuery(sql);
		List<UserOrderDetail> list = queryH.list();	
		return list;
	}
	

	
}
